package com.autumn.chat.http;

import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import com.autumn.chat.config.GlobalParam;
import com.autumn.chat.constant.BiLiBiLiConstant;

public class DoBLiveApi extends BLiveHttpClient {


    /**
     * 获取直播间信息 /start
     */
    public static String getStart() {
        // 拼接url
        String startUrl = BiLiBiLiConstant.BASE_URL + BiLiBiLiConstant.URL_START;
        // 拼接body
        JSONObject requestBody = new JSONObject();
        requestBody.put("code", GlobalParam.AUTH_ID);
        requestBody.put("app_id", GlobalParam.APP_ID);

        // 发送请求获取直播间信息
        HttpResponse execute = BLiveHttpClient.getCommonHttpRequest(startUrl, requestBody).execute();

        return execute.body();
    }

    /**
     * 关闭直播间
     * @return
     */
    public static String getEnd(String gameId) {
        String endUrl = BiLiBiLiConstant.BASE_URL + BiLiBiLiConstant.URL_END;
        // 拼接body
        JSONObject requestBody = new JSONObject();
        requestBody.put("app_id", GlobalParam.APP_ID);
        requestBody.put("game_id", gameId);

        // 发送请求获取直播间信息
        HttpResponse execute = getCommonHttpRequest(endUrl, requestBody).execute();

        return execute.body();
    }

    public static String sendHearBeat(String gameId) {
        String hearBeatUrl = BiLiBiLiConstant.BASE_URL + BiLiBiLiConstant.URL_HEAR_BEAT;

        // 拼接body
        JSONObject requestBody = new JSONObject();
        requestBody.put("game_id", gameId);

        // 发送请求获取直播间信息
        HttpResponse execute = getCommonHttpRequest(hearBeatUrl, requestBody).execute();
        return execute.body();
    }

}
